package tech.aistar.corejava.day06.day06work.Test01;

/**
 * 信用账户
 * Created by 豆梦寒 on 2019/7/22.
 */
public class CreditAccount extends Account {
    private Integer balance;
    private double credit;
    private double accbalance;//账户余额
    private String accPassword;//密码

    public CreditAccount() {
    }

    public CreditAccount(Integer balance, double credit, double accbalance, String accPassword) {
        this.balance = balance;
        this.credit = credit;
        this.accbalance = accbalance;
        this.accPassword = accPassword;
    }

    public Integer getBalance() {
        return balance;
    }

    public void setBalance(Integer balance) {
        this.balance = balance;
    }

    public double getCredit() {
        return credit;
    }

    public void setCredit(double credit) {
        this.credit = credit;
    }


    public double getAccbalance() {
        return accbalance;
    }

    public void setAccbalance(double accbalance) {
        this.accbalance = accbalance;
    }


    public String getAccPassword() {
        return accPassword;
    }


    public void setAccPassword(String accPassword) {
        this.accPassword = accPassword;
    }


    public String toString() {
        final StringBuilder sb = new StringBuilder("CreditAccount{");
        sb.append("balance=").append(balance);
        sb.append(", credit=").append(credit);
        sb.append(", accbalance=").append(accbalance);
        sb.append(", accPassword='").append(accPassword).append('\'');
        sb.append('}');
        return sb.toString();
    }

    @Override
    public void withdrawl(String password,double turnover)
    {
        if(this.accPassword!=password)
        {
            System.out.println("抱歉，你输入的密码有误");
            return ;
        }
        if(accbalance-turnover>0)
        {
            System.out.println("您已取出"+turnover+"元"+"当前余额为"+(accbalance-turnover));
        }
        else if(accbalance-turnover<0)
        {

            System.out.println("抱歉，你的余额已不足,将要透支。");
        }
        if(credit<500){
            System.out.println("抱歉，您的信用太低，不能透支");

        }else{
            System.out.println(credit=credit-(turnover-accbalance));
        }

    }



}
